<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Debugging reference count problems</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GObject Reference Manual">
<link rel="up" href="pt03.html" title="Part V. Related Tools">
<link rel="prev" href="tools-ginspector.html" title="Graphical inspection of GObjects">
<link rel="next" href="tools-gtkdoc.html" title="Writing API docs">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="tools-ginspector.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="pt03.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GObject Reference Manual</th>
<td><a accesskey="n" href="tools-gtkdoc.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="tools-refdb"></a>Debugging reference count problems</h2></div></div></div>
<p>
      The reference counting scheme used by GObject does solve quite 
      a few memory management problems but also introduces new sources of bugs.
      In large applications, finding the exact spot where the reference count
      of an Object is not properly handled can be very difficult. Hopefully, 
      there exist a tool named <a class="ulink" href="http://refdbg.sf.net/" target="_top">refdbg</a>
      which can be used to automate the task of tracking down the location
      of invalid code with regard to reference counting. This application 
      intercepts the reference counting calls and tries to detect invalid behavior. 
      It supports a filter-rule mechanism to let you trace only the objects you are 
      interested in and it can be used together with GDB.
    </p>
<p>
      
      Note that if GObject has been compiled with <code class="option">--enable-debug=yes</code>,
      it exports a trap variable 
      </p>
<pre class="programlisting">
static volatile GObject *g_trap_object_ref;
      </pre>
<p>
      If set to a non-NULL value, <a class="link" href="gobject-The-Base-Object-Type.html#g-object-ref" title="g_object_ref ()">g_object_ref</a>()
      and <a class="link" href="gobject-The-Base-Object-Type.html#g-object-unref" title="g_object_unref ()">g_object_unref</a>() will be intercepted
      when called with that value. 
    </p>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>